import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisPoolOptimizeTest {
    public static void main(String[] args) {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(10);
        jedisPoolConfig.setMaxWaitMillis(1000);

        JedisPool jedisPool = new JedisPool(jedisPoolConfig, "127.0.0.1", 6379);

        for (int i = 0; i < 10; i++) {
            Jedis jedis = null;
            try {
                jedis = jedisPool.getResource();
                System.out.println(jedis.ping());
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                jedis.close();
            }
        }

        jedisPool.getResource().ping();
    }
}
